<?php
class FileFromDB {

	private $filename;
	public function __construct($filename) {

		$this->filename = $filename;
	}

	public function upload($file) {
		global $PDO;
		$stmt = $PDO->prepare("INSERT INTO FILE (name, type, data) VALUES (?, ?, ?)");
		$stmt->bindParam(1, $this->filename);
		$stmt->bindParam(2, $file['type']);
		$stmt->bindParam(3, fopen($file['tmp_name'], 'rt'), PDO::PARAM_LOB);
		return $stmt->execute();
	}
}
?>